package testsJUnit;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestBase;

public class TestsMemberActions extends SeleneseTestBase {

	@Before
	public void setUp() throws Exception {
		selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080/");
		selenium.start();
		selenium.open("/to5-veilingsite/Menu.action");
		selenium.click("link=Inloggen");
		selenium.waitForPageToLoad("30000");
		selenium.type("id=Login_username", "frits");
		selenium.type("id=Login_password", "Frits123");
		selenium.click("id=Login_0");
		selenium.waitForPageToLoad("30000");
		//selenium.open("/to5-veilingsite/visitor/Login.action");
	}
	
	@Test
	public void testTestMaakVeiling() throws Exception {
		
		selenium.click("link=Account");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=Maak veiling");
		selenium.waitForPageToLoad("30000");
		selenium.type("id=VeilingAction_naam", "KiteSurf Package");
		selenium.type("id=VeilingAction_beschrijving", "Nieuw kiteSurf Package inclusief board");
		selenium.type("id=VeilingAction_minimum", "2000");
		selenium.select("id=VeilingAction_categorie", "label=watersport");
		selenium.type("id=VeilingAction_pics", "C:\\Users\\Public\\Pictures\\Sample Pictures\\kitesurfintermediate2.jpg");
		selenium.click("id=VeilingAction_0");
		selenium.waitForPageToLoad("30000");
		assertTrue(selenium.isTextPresent("Veiling gemaakt"));
	}
	
	@Test
	public void testTestWijzigGegevens() throws Exception {
		selenium.click("link=Account");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=Wijzig gegevens");
		selenium.waitForPageToLoad("30000");
		selenium.type("id=UpdateAccount_password", "Frits123");
		selenium.type("id=UpdateAccount_passwordRepeat", "Frits123");
		selenium.type("id=UpdateAccount_adres", "Voorstraat 44");
		selenium.type("id=UpdateAccount_emailRepeat", "F@live.nl");
		selenium.click("id=UpdateAccount_0");
		selenium.waitForPageToLoad("30000");
		assertTrue(selenium.isTextPresent("Ingelogd"));
	}
	@Test
	public void testTestWijzigVeiling() throws Exception {
		selenium.click("link=Account");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=Mijn veilingen");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=Wijzig veiling");
		selenium.waitForPageToLoad("30000");
		selenium.type("id=UpdateVeiling_beschrijving", "Nieuw 2 per yetski 2012");
		selenium.click("id=UpdateVeiling_0");
		selenium.waitForPageToLoad("30000");
		assertTrue(selenium.isTextPresent("Ingelogd"));
	}
	@Test
	public void testTestKoopKrediet() throws Exception {
		selenium.click("link=Account");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=Koop Credit");
		selenium.waitForPageToLoad("30000");
		selenium.type("id=BuyCredits_aantal", "10000");
		selenium.click("id=BuyCredits_0");
		selenium.waitForPageToLoad("30000");
		assertTrue(selenium.isTextPresent("Ingelogd"));
	}
	@Test
	public void testTestPlaatsBod() throws Exception {
		selenium.click("link=Account");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=alle categorien");
		selenium.waitForPageToLoad("30000");
		selenium.click("//table[@id='resultatenTabel']/tbody/tr[4]/td[2]");
		selenium.waitForPageToLoad("30000");
		selenium.type("id=Bied_bod", "7700");
		selenium.click("id=Bied_0");
		selenium.waitForPageToLoad("30000");
		assertTrue(selenium.isTextPresent("Beschrijving"));
	}
	
	@After
	public void tearDown() throws Exception {
		selenium.stop();
	}

}
